<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>曲线图-(动态)</title>
<link rel="stylesheet" type="text/css" href="css/highchart.css">
</head>
<body>
	<div id="container" style="width:600px;height:400px"></div>
</body>
<script type="text/javascript" src="js/jquery/jquery-1.8.3.min.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script src="js/modules/export-csv.js"></script>
<script src="js/lang/highcharts-lang-cn.js"></script>
<script type="text/javascript">
	$(function() {
		$(document).ready(function() {
			Highcharts.setOptions({
				global : {
					useUTC : true
				}
			});

			$('#container').highcharts({
				chart : {
					type : 'spline',
					animation : Highcharts.svg, // don't animate in old IE
					marginRight : 10,
					events : {
						load : function() {

							// set up the updating of the chart each second
							var series = this.series[0];
							setInterval(function() {
								var x = (new Date()).getTime(), // current time
								y = Math.random();
								series.addPoint([ x, y ], true, true);
							}, 1000);
						}
					}
				},
				title : {
					text : '动态随机数据'
				},
				xAxis : {
					title : {
						text : '时间'
					},
					type : 'datetime',
					tickPixelInterval : 150
				},
				yAxis : {
					title : {
						text : '值'
					},
					plotLines : [ {
						value : 0,
						width : 1,
						color : '#808080'
					} ]
				},
				tooltip : {
					formatter : function() {
						var tipArr = [];
						tipArr.push('<b>');
						tipArr.push(this.series.name);
						tipArr.push('</b><br/>');
						tipArr.push(Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x));
						tipArr.push('<br />');
						tipArr.push('<span style="color:'+this.series.color+'">');
						tipArr.push(Highcharts.numberFormat(this.y, 2));
						tipArr.push('</span>');

						return tipArr.join("");
						;
					}
				},
				legend : {
					enabled : false
				},
				exporting : {
					enabled : false
				},
				series : [ {
					name : '随机数据',
					data : (function() {
						var data = [], time = (new Date()).getTime(), i;

						for (i = -19; i <= 0; i += 1) {
							data.push({
								x : time + i * 1000,
								y : Math.random()
							});
						}
						return data;
					}())
				} ]
			});
		});
	});
</script>
</html>